#include "onethread.h"
#include <sstream>
#include <iostream>
using namespace std;
OneThread::OneThread(QObject *parent) :
        QThread(parent)
{
}

void OneThread::run()
{
    int i=0;
    while(this->roulette->checkNumberOfRobots())
    {
        i++;
        std::cout<<std::endl<<"----in TokenRoulette::run() --- iteration"<<i<<std::endl;
        this->roulette->run();
        std::cout<<"----iteration roulette ended"<<std::endl<<std::endl;
        this->usleep(200000);

        this->roulette->ws->printStage();

        std::list<Robot*>::iterator r;
        std::cout<<std::endl;
        for (r = this->roulette->ws->robots.begin();r!=this->roulette->ws->robots.end();++r) {
            (*r)->printPath();std::cout<<", is at ";
            if ((*r)->getOccupiedCell()==NULL)
                cout<<"somewhere near stage";
            else
                (*r)->getOccupiedCell()->printCell() ; cout << endl;
        }
    }
    std::cout << "\nStage is empty\n";
    this->roulette->ws->printStage();
}
